﻿using GenericRepositoryDemo.Domain.Orders;
using GenericRepositoryDemo.Infrastructure.Abstracts.Repositories;
using GenericRepositoryDemo.Infrastructure.EfCore;
using Microsoft.EntityFrameworkCore;

namespace GenericRepositoryDemo.Infrastructure.Orders
{
    public class OrderCustomRepository : EfCoreRepositoryBase<AppDbContext, Order, int>, IOrderCustomRepository
    {
        public OrderCustomRepository(AppDbContext dbContext) : base(dbContext)
        {
        }

        public async Task<int> GetEmergencyOrderCount()
        {
            var dbContext = await GetDbContextAsync();
            return await dbContext.Orders
              .AsNoTracking()
              .Where(o => o.Id == 1)
              .CountAsync();
        }
    }
}
